package com.visionet.school.app.web.task;

import com.visionet.school.app.web.common.utils.DownLoadFileUtils;
import com.visionet.school.app.web.entity.enums.FileEnums;
import com.visionet.school.app.web.entity.file.FileClass;
import com.visionet.school.app.web.entity.file.vo.FileVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;

import java.util.concurrent.Callable;

/**
 * Created by hxpeng on 2017/3/29.
 */
public class DownLoadFileTask implements Callable<FileClass> {

    private static final Logger logger = LoggerFactory.getLogger(DownLoadFileTask.class);

    private String mediaId;

    private String savePath;

    public DownLoadFileTask(String mediaId,String savePath){
        this.mediaId = mediaId;
        this.savePath = savePath;
    }

    @Override
    public FileClass call() throws Exception {
        FileClass fileClass = new FileClass();
        FileVo fileVo = DownLoadFileUtils.downloadWechatFile(mediaId,savePath,true, FileEnums.IMG.toKey());
        BeanUtils.copyProperties(fileVo,fileClass);
        fileClass.setIsDeleted("0");
        return fileClass;
    }
}
